package com.example.student.util;

import java.util.regex.Pattern;

/**
 * @author TonySong
 * @date 2025/8/15 0015
 * @time 15:49
 */
public class PatternUtils {

    private static final String REGEX_EMAIL = "^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\\.[a-zA-Z0-9_-]+)+$";
    private static final String REGEX_CHINESE = "^[\u4E00-\u9FA5]+$";
    private static final String REGEX_PASSWORD ="^[a-zA-Z0-9_-]{6,16}$";
    private static final String REGEX_USERNAME ="^[a-zA-Z0-9_-]{3,10}$";
    private static final String REGEX_AGE ="^[0-9]{1,3}$";

    private static final String REGEX_MOBILE = "^1[34578]\\d{9}$";
    private static final String REGEX_IDENTITY="^[1-9]\\d{5}(18|19|([23]\\d))\\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\\d{3}[0-9Xx]$";

    public static  boolean isEmail(String email) {
        return  Pattern.matches(REGEX_EMAIL,email);
    }

    public static boolean isChinese(String chinese) {
        return Pattern.matches(REGEX_CHINESE,chinese);
    }

    public static boolean isPassword(String password) {
        return Pattern.matches(REGEX_PASSWORD,password);
    }

    public static boolean isUsername(String username){
        return  Pattern.matches(REGEX_USERNAME,username);
    }

    public static boolean isAge(String age){
        return Pattern.matches(REGEX_AGE,age);
    }

    public static boolean isIdentity(String identity){
        return Pattern.matches(REGEX_IDENTITY,identity);
    }

    public static boolean isMobile(String mobile){
        return Pattern.matches(REGEX_MOBILE,mobile);
    }
}
